package cn.com.infcn.monitor.task.web;

import java.util.List;

import cn.com.infcn.monitor.bean.IFCHttpSession;
import cn.com.infcn.monitor.listener.IFCSessionInformations;
import cn.com.infcn.monitor.listener.IFCSessionListener;
import cn.com.infcn.monitor.task.BaseTask;

public class HttpSessionTask implements BaseTask{
	private boolean isDetail = false;
	
	public HttpSessionTask(){
	}
	
	public HttpSessionTask(boolean isDetail) {
		this.isDetail = isDetail;
	}

	@Override
	public IFCHttpSession execute() throws Exception {
		return httpSession();
	}
	
	public IFCHttpSession httpSession(){
		IFCHttpSession httpSession = new IFCHttpSession();
		
		//当前在线人数
		httpSession.setOnlineUserCount(IFCSessionListener.getSessionCount());
		httpSession.setGetSessionAgeSum(IFCSessionListener.getSessionAgeSum());
		
		if(isDetail){
			List<IFCSessionInformations> sessionDetailList = IFCSessionListener.getAllSessionsInformations();
			httpSession.setSessionDetailList(sessionDetailList);
		}
		
		return httpSession;
	}
	
}
